<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 
    
<title>车辆入库</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css"
	href="${ctx }/resources/easyui/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${ctx }/resources/css/icon.css">
<link rel="stylesheet" type="text/css" href="${ctx }/resources/css/wu.css" />
<script type="text/javascript" src="${ctx }/resources/easyui/jquery.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/easyui/datagrid-detailview.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/easyui/locale/easyui-lang-zh_CN.js"></script>
</head>

<body class="easyui-layout">
	<!-- 查询条件开始 -->
	<div class="easyui-panel" data-options="region:'north',split:true,title:'查询条件',iconCls:'icon-search'" 
		style="width:100%;text-align: center;height: 100px;padding: 15px">
        <input class="easyui-searchbox" id="searchboxvalue" data-options="prompt:'请输入出租单号',searcher:doSearch" style="width:50%;">
	</div>
	<!-- 查询条件结束 -->
	 <!-- 数据表格开始 -->
    <div id="content" class="easyui-panel" data-options="region:'center',border:false">
    	<!-- 检查单表单开始 -->
    	<div class="easyui-panel" data-options="title:'生成检查单',iconCls:'icon-save'" style="width: 100%">
    		<form action="" method="post" id="fm">
	    		<table width="100%" cellpadding="5">
	    			<tr>
	    				<td width="10%" align="right"> <label>检查单号:</label></td>
	    				<td width="40%">
	    					 <input name="checkid" readonly="readonly" id="checkid" class="easyui-textbox" required="true" style="width:80%">
	    				</td>
	    				<td width="10%" align="right"><label>检查时间:</label></td>
	    			 <td width="40%">
	    					 <input name="checkdate"  class="easyui-datebox" required="true" style="width:80%">
	    				</td> 
	    			</tr>
	    			<tr>
	    				<td width="10%" align="right"> <label>出租单号:</label></td>
	    				<td width="40%">
	    					 <input name="rentid" id="rentid" readonly="readonly" class="easyui-textbox" required="true" style="width:80%">
	    				</td>
	    				<td width="10%" align="right"><label>操作员:</label></td>
	    				<td width="40%">
	    					 <input name="opername"  id="opername" readonly="readonly" class="easyui-textbox" required="true" style="width:80%">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td width="10%" align="right"> <label>存在问题:</label></td>
	    				<td width="40%">
	    					 <input name="problem"  class="easyui-textbox" required="true" style="width:80%">
	    				</td>
	    				<td width="10%" align="right"><label>赔付金额:</label></td>
	    				<td width="40%">
	    					 <input name="paymoney"   class="easyui-textbox" required="true" style="width:80%">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td width="10%" align="right"> <label>问题描述:</label></td>
	    				<td width="90%" colspan="3">
	    					 <input name="checkdesc"  multiline="true" class="easyui-textbox" required="true" style="width:91%;height: 50px">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td width="90%" colspan="4" align="center">
	    				 <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveCheck()" style="width:90px">保存</a>
	    				</td>
	    			</tr>
	    		</table>
    		</form>
    	</div>
    	<!-- 检查单表单结束 -->
    	<div style="height: 2px"></div>
    	<!-- 相关的联信息开始-->
    	<div class="easyui-layout" style="width: 100%;height: 220px">
    		<!-- 车辆信息 -->
    		<div class="easyui-panel" data-options="region:'west',title:'车辆信息',iconCls:'icon-tip'" style="width: 33.333%">
				 <table align="center" width="90%" cellpadding="5">
				   	<tr>
				   		<td align="right" width="30%"> <label>车辆号牌:</label> </td>
				   		<td width="70%"> <label id="car_carnumber"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>车辆类型:</label> </td>
				   		<td width="70%"> <label id="car_cartype"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>车辆颜色:</label> </td>
				   		<td width="70%"> <label id="car_color"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>车辆价格:</label> </td>
				   		<td width="70%"> <label id="car_price"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>默认出租价格:</label> </td>
				   		<td width="70%"> <label id="car_rentprice"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>出租押金:</label> </td>
				   		<td width="70%"> <label id="car_deposit"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>车辆描述:</label> </td>
				   		<td width="70%"> <label id="car_description"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>车辆图片:</label> </td>
				   		<td width="70%"> 
				   			<img alt="" width="100%" id="car_carimg" height="100" src="../resources/images/defaultcarimg.jpg">
				   		 </td>
				   	</tr>
				 </table>
    		</div>
    		<!-- 出租单信息 -->
    		<div class="easyui-panel" data-options="region:'center',title:'出租单信息',iconCls:'icon-tip'" style="width: 33.333%">
				  <table align="center" width="90%" cellpadding="5">
				   	<tr>
				   		<td align="right" width="30%"> <label>出租单号:</label> </td>
				   		<td width="70%"> <label id="rent_rentid"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>出租价格:</label> </td>
				   		<td width="70%"> <label id="rent_price"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>起租时间:</label> </td>
				   		<td width="70%"> <label id="rent_begindate"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>还车时间:</label> </td>
				   		<td width="70%"> <label id="rent_returndate"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>操作员:</label> </td>
				   		<td width="70%"> <label id="rent_opername"></label>  </td>
				   	</tr>
				 </table>	   			
    		</div>
    		<!-- 客户信息 -->
    		<div class="easyui-panel" data-options="region:'east',title:'客户信息',iconCls:'icon-tip'" style="width: 33.333%">
				  <table align="center" width="90%" cellpadding="5">
				   	<tr>
				   		<td align="right" width="30%"> <label>身份证号:</label> </td>
				   		<td width="70%"> <label id="customer_identity"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>客户姓名:</label> </td>
				   		<td width="70%"> <label id="customer_custname"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>客户性别:</label> </td>
				   		<td width="70%"> <label id="customer_sex"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>客户地址:</label> </td>
				   		<td width="70%"> <label id="customer_address"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>客户职位:</label> </td>
				   		<td width="70%"> <label id="customer_career"></label>  </td>
				   	</tr>
				   	<tr>
				   		<td align="right" width="30%"> <label>客户电话:</label> </td>
				   		<td width="70%"> <label id="customer_phone"></label>  </td>
				   	</tr>
				 </table>			
    		</div>
    	</div>
    	<!-- 相关的联信息结束-->
    </div>
	<script type="text/javascript">
	
		$(function(){
			$("#content").hide();
		});
		//查询
		function doSearch(value){
			//发送请求
			$.post("${ctx}/rent/loadRentByRentId.action",{rentid:value},function(obj){
				if(obj===""){
					$("#content").hide();
					$.messager.show({
						title:'提示',
						msg:'您输入的出租单号不存在'
					});
				}else{
					if(obj.rentflag==1){
						$("#content").hide();
						$.messager.show({
							title:'提示',
							msg:'该出租单号的相关车辆已归还'
						});
					}else{
						$("#content").show();
						$.post("${ctx}/check/loadCheckFormMsg.action",{rentid:$("#searchboxvalue").val()},function(obj){
							
							var check=obj.check;
							//装载表单
							$("#fm").form("load",check);
							var rent=obj.rent;
							//加载出租单信息
							$("#rent_rentid").html(rent.rentid);
							$("#rent_price").html(rent.price);
							$("#rent_begindate").html(rent.begindate);
							$("#rent_returndate").html(rent.returndate);
							$("#rent_opername").html(rent.opername);
							var customer=obj.customer;
							$("#customer_identity").html(customer.identity);
							$("#customer_custname").html(customer.custname);
							$("#customer_sex").html(customer.sex==1?'男':'女');
							$("#customer_address").html(customer.address);
							$("#customer_career").html(customer.career);
							$("#customer_phone").html(customer.phone);
							var car=obj.car;
							$("#car_carnumber").html(car.carnumber);
							$("#car_cartype").html(car.cartype);
							$("#car_color").html(car.color);
							$("#car_price").html(car.price);
							$("#car_rentprice").html(car.rentprice);
							$("#car_deposit").html(car.deposit);
							$("#car_description").html(car.description);
							$("#car_carimg").attr({src:car.carimg});
						});
					}
				}
			});
		};
		
		 function saveCheck(){
			 $.messager.progress();	// 显示进度条
				$('#fm').form('submit', {
					url: "${ctx}/check/addCheck.action",//数据提交地址  user/addRent.action
					onSubmit: function(){
						var isValid = $(this).form('validate');//对表单里面的required:true和vailType的数据进行验证
						if (!isValid){
							$.messager.progress('close');	// 如果验证失败关闭进度条
						}
						return isValid;	//返回验证结果
					},
					success: function(obj){//如果提交成功之后回调的方法
						$.messager.progress('close');	// 关闭进度条
	                    var result = eval('('+obj+')');//把obj的josn字符串转成js认识的json对象
						$.messager.show({
							title:'提示',
							msg:result.msg
						});
						$("#content").hide();
					}
				});
		 }
	
		
	</script>
</body>
</html>
